<template>
	<view class="contain ">
		<view class="title1" @click="goback"><u-icon name="arrow-left" color="white" size="50rpx"></u-icon></view>
		<view class="title">
			<view style="overflow: hidden;width: 160rpx; height: 160rpx;border-radius: 40rpx;">
				<image src="https://xgr.oss-cn-hangzhou.aliyuncs.com/icon/WechatIMG2024121214101.jpg" mode=""
					style="width: 160rpx; height: 160rpx;"></image>
			</view>
			<view style="margin-left: 40rpx;">
				找活招工
				<br />
				就到天下工人
			</view>

		</view>
		<view class="content">
			<view class="p1">
				{{opt.inviter}}邀你加入
			</view>
			<view class="p1">
				{{opt.entname}}
			</view>
			<view v-if="status == 0" class="input">
				<u--input placeholder="请填写您的真实姓名" border="surround" v-model="message.realName" shape='circle'
					customStyle='background-color:#ffffff'></u--input>
			</view>
			<view style="width: 80%;margin: auto;margin-top: 40rpx;">
				<u-input placeholder="填写手机号" border="surround" v-model="message.mobile" shape='circle'
					customStyle='background-color:#ffffff'>
				</u-input>
			</view>
			<view v-if="status == 0" style="width: 80%;margin: auto;margin-top: 40rpx;">
				<u-input placeholder="填写身份证号" border="surround" v-model="message.idCardNo" shape='circle'
					customStyle='background-color:#ffffff'>
				</u-input>
			</view>
			<view class="btn">
				<u-button type="primary" text="提交" @click="invitednext()"></u-button>
			</view>
		</view>
		<view class="">
			
		</view>
		
		<u-overlay :show="showuploadImage">
				<view class="autloading" style="width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;">
					<u-loading-icon :show="showuploadImage" color="white"></u-loading-icon>
				</view>
				
		</u-overlay>
		<!-- <button type="primary" open-type="launchApp" binderror="launchAppError" style="border-radius: 40rpx;width: 40%;position: relative;top: 300rpx">前往APP</button> -->
	</view>
	
</template>

<script>
	import Index from '@/common/index-model.js'
	let index = new Index();
	let that = null;
	export default {
		data() {
			return {
				opt:'',
				message:{
					enterpriseId:'',
					realName:'',
					mobile:'',
					idCardNo:''
				},
				status:'',
			}
		},
		onLoad(option) {
			if(option){
				console.log(option)
				this.opt = option
				if(option.entpname||option.entname||option.inviter||option.entid){
					this.opt.entpname = decodeURIComponent(option.entpname)
					this.opt.entname = decodeURIComponent(option.entname)
					this.opt.inviter = decodeURIComponent(option.inviter)
					this.message.enterpriseId = Number(decodeURIComponent(option.entid))
				}
				this.getRz()
				console.log(this.opt)
			}
			if (!uni.getStorageSync('token')) {
				index.show_tips('请先登录')
				setTimeout(() => {
					index.navigate_to('../../pagesC/login/login');
					//index.navigate_back(1)
				}, 300)
			}
		},
		methods: {
			getRz() {
				index.getPublicUserMember({},'client/realauth/nameInfo','get',res=>{
					if(res.data.code == 200 && res.data.success){
						console.log(res)
						let arr = res.data.result
						this.status = arr.status
						this.message.realName = arr.realName?arr.realName:''
						this.message.idCardNo = arr.cardNo?arr.cardNo:''
					}else{
						this.status = 0
					}
				})
			},
			goback(){
				index.switch_tab("/pages/index/index")
			},
			invitednext(){
				if(this.opt){
					if(this.opt.entpname == this.message.realName&&this.opt.entpnum == this.message.mobile){
						console.log(this.message)
						index.getPublicUserMember(this.message,'/apclient/enterprisePermission/inviteUser','post',res=>{
							if(res.data.code == 200 && res.data.success){
								index.show_tips("加入成功")
								setTimeout(()=>{
									index.switch_tab("/pages/index/index")
								},1500)
							}else{
								index.show_tips(res.data.message);
								return false
							}
						})
					}else{
						index.show_tips("您的实名信息或电话与邀请人填写的不符")
						setTimeout(()=>{
							index.switch_tab("/pages/index/index")
						},1500)
						
					}
				}
			},
		}
	}
</script>

style>
	@import url("@/static/css/publics.css");
	@import url("@/static/css/login.css");
</style>
<style scoped>
	page {
		width: 100%;
		height: 100%;
		background-color: #FfF3F3;
	}
.title1{
	padding-top: 100rpx;
	margin-left: 40rpx;
}
	.title {
		font-size: 60rpx;
		color: #FFFFFF;
		margin: auto;
		margin-top: 100rpx;
		width: 80%;
		display: flex;
		align-items: center;
	}
	.content{
		margin: 100rpx auto;
		background-color: white;
		width: 80%;
		padding: 40rpx 0;
		border-radius: 20rpx;
		box-shadow:#e0e0e0 0px 0px 10px;
		
	}
	.p1{
		color: #555555;
		font-size: 28rpx;
		text-align: center;
	}
	.tip {
		font-size: 30rpx;
		color: #555555;
		margin: auto;
		margin-top: 200rpx;
		width: 80%;
	}

	.contain {
		background: linear-gradient(180deg, #8DC0FF 0%, rgba(255,255,255,0.00) 70%);
		/* height: 100vh; */
		/* background-image: url('https://xgr.oss-cn-hangzhou.aliyuncs.com/icon/WechatIMG2024121211541.jpg'); */
		background-size: 100% 100%;
		overflow-x: hidden;
		overflow-y: hidden;
	}

	.input {
		margin: auto;
		margin-top: 20rpx;
		width: 80%;
	}

	.btn {
		width: 80%;
		margin: auto;
		margin-top: 40rpx;

	}
</style>
